import QtQuick 2.6
import Qt.labs.controls 1.0
import QtQuick.Layouts 1.1
import QtQuick.XmlListModel 2.0
import "../template" as Template
import "../js/RecordSignManagerNavigator.qml.js" as Jit

Template.Navigator {
    id: nav
    title: "签到记录"
    property string uid: ""
    property string name: ""


    ColumnLayout {
        anchors.fill: parent
        ListView {
            id: view
            Layout.fillHeight: true
            Layout.fillWidth: true

            model: XmlListModel {
                id: xmlModel
                source: http.build("/sign.xml?t=q", {uid: nav.uid})
                query: "/signs/sign"

                XmlRole { name: "id"; query: "id/string()" }
                XmlRole { name: "name"; query: "member/name/string()" }
                 XmlRole { name: "date"; query: "date/string()" }
                 XmlRole { name: "tm1"; query: "tm1/string()" }
                 XmlRole { name: "tm2"; query: "tm2/string()" }
                  XmlRole { name: "description"; query: "description/string()" }
                  XmlRole { name: "memberid"; query: "member/id/string()" }
                   XmlRole { name: "membername"; query: "member/display/string()" }
                   XmlRole { name: "placeid"; query: "place/id/string()" }
                    XmlRole { name: "placename"; query: "place/display/string()" }
                    XmlRole { name: "courseid"; query: "course/id/string()" }
                     XmlRole { name: "coursename"; query: "course/display/string()" }
            }

            delegate: ItemDelegate {
                id: delegate
                width: view.width
                height: implicitHeight * 4.5

                ColumnLayout {
                    anchors.fill: parent


                    Label {
                        text: "姓名：" + name + " 日期：" + date
                    }

                    Label {
                        text: "起始时间：" + tm1
                    }
                    Label {
                        text: "终止时间：" + tm2
                    }
                    Label {
                        text: "场地：" + placename
                    }
                    Label {
                        text: "课程：" + coursename
                    }
                    Label {
                        text: "说明：" + description
                    }
                }

                Rectangle {
                    color: "forestgreen"
                    width: parent.width
                    height: 1
                    anchors.bottom: parent.bottom
                    visible: index != view.count - 1
                }
            }
        }
    }
}
